{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Install some packages\n",
    "# !conda install pandas scikit-learn matplotlib seaborn -y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd \n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Read Data from Raw\n",
    "CHARLS_D=\"../Data/raw/H_CHARLS_d.dta\"\n",
    "CHARLS_EOL=\"../Data/raw/H_CHARLS_EOL_a.dta\"\n",
    "CHARLS_LH=\"../Data/raw/H_CHARLS_LH_a.dta\"\n",
    "\n",
    "df_charls_d   = pd.read_stata(CHARLS_D)\n",
    "df_charls_eof = pd.read_stata(CHARLS_EOL)\n",
    "df_charls_LH  = pd.read_stata(CHARLS_LH)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Export Data information\n",
    "def exportDfInfo(dfList:list,sheetNames:list):\n",
    "    writer=pd.ExcelWriter(\"../Documents/Variables information.xlsx\")\n",
    "    for df,sheet in zip(dfList,sheetNames):\n",
    "        info={\n",
    "            \"Variables\":df.columns.tolist(),                           # columns  name\n",
    "            \"Type\":df.dtypes.astype('str').tolist(),                   # columnas type\n",
    "            \"Missing\":df.isna().sum()                                  # columns missing summary\n",
    "            }\n",
    "        pd.DataFrame(info).to_excel(writer,sheet_name=sheet,index=False)\n",
    "    writer.close()\n",
    "\n",
    "exportDfInfo(dfList=[df_charls_d,df_charls_eof,df_charls_LH],\n",
    "             sheetNames=['df_charls_d','df_charls_eof','df_charls_LH'])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
